﻿using System;

namespace SqlCommandHelper
{
    /// <summary>
    /// Sql Server table field attribute
    /// </summary>
    public class DbField : Attribute
    {
        #region Properties
        /// <summary>
        /// Gets the CustomName.
        /// </summary>
        /// <value>
        /// The CustomName.
        /// </value>
        public string CustomName { get; set; }

        /// <summary>
        /// Gets the StoredProcedure parameter name
        /// <value>
        /// The Prameter name
        /// </value>
        /// </summary>
        public string StoredProcedureParameterName { get; set; }

        #endregion

        #region Constructor(s)

        /// <summary>
        /// Initializes a new instance of the <see cref="DbField"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        public DbField(string name)
        {
            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name", "cannot be null or empty");
            this.CustomName = name;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DbField"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="storedProcedureName">the stored procedure name.</param>
        public DbField(string name, string storedProcedureName)
        {
            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name", "cannot be null or empty");
            if (string.IsNullOrEmpty(storedProcedureName)) throw new ArgumentNullException("storedProcedureName", "cannot be null or empty");

            this.CustomName = name;
            this.StoredProcedureParameterName = storedProcedureName;
        }

        /// <summary>
        /// Create a new instance of <see cref="DbField"/> class.
        /// </summary>
        public DbField() { }
        #endregion
    }
}
